/**
 * @auth: sce
 * @date: 1/9/18
 * @desc:  返回文件的md5值
 **/

const fs = require('fs');
const crypto = require('crypto');


const md5Cli = async (path, callback) => {
    const md5Hash = crypto.createHash("md5");
    const stream = fs.createReadStream(path);
    stream.on('data', (chunk) => {
        md5Hash.update(chunk);
    });
    stream.on("end", () => {
        callback(md5Hash.digest('hex'));
    })

};


module.exports = md5Cli;